package com.haorui.lygyd.wxapi.controller;

import com.haorui.base.core.exception.BusinessException;
import com.haorui.lygyd.employeemanager.entity.MemberEntity;
import com.haorui.lygyd.wxapi.dto.WXMemberUpdatePassDto;
import com.haorui.lygyd.wxapi.entity.WXUserInfoEntity;
import com.haorui.lygyd.wxapi.service.WXMemberService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author 郭飞
 * @version 1.0
 * @project znsm
 * @package com.haorui.membermanager.controller
 * @createDate 2017/9/26 0026 9:49
 * @modfiyDate
 * @function 微信会员接口
 */
@RestController
@RequestMapping(value = "/wx/wxmember")
public class WXMemberController {

    @Autowired
    private WXMemberService wxMemberService;

    @ApiOperation(value = "获取验证码", notes = "无返回值", position = 2)
    @RequestMapping(value = "/wxgetYanZhengMa/{shoujihao}", method = RequestMethod.GET)
    public void wxgetYanZhengMa(@PathVariable String shoujihao) throws BusinessException {
        wxMemberService.wxgetYanZhengMa(shoujihao);
    }

    @ApiOperation(value = "个人信息", notes = "返回的会员信息", position = 2)
    @RequestMapping(value = "/wxselectMemberDetail", method = RequestMethod.GET)
    public MemberEntity wxselectMemberDetail() throws BusinessException {
        return wxMemberService.wxselectMemberDetail();
    }

    @ApiOperation(value = "修改密码", notes = "返回修改后的会员信息", position = 2)
    @RequestMapping(value = "/wxmemberUpdatePass", method = {RequestMethod.PUT,RequestMethod.PATCH})
    public MemberEntity wxmemberUpdatePass(@RequestBody WXMemberUpdatePassDto dto) throws BusinessException {
        return  wxMemberService.wxmemberUpdatePass(dto);
    }


    @ApiOperation(value = "用户头像", notes = "返回头像地址", position = 2)
    @RequestMapping(value = "/wxgetPhotoWeixin", method = RequestMethod.GET)
    public WXUserInfoEntity wxgetPhotoWeixin() throws BusinessException {
        return wxMemberService.getPhotoWeixin();
    }

    @ApiOperation(value = "验证密码是否正确", notes = "返回true或fasle", position = 2)
    @RequestMapping(value = "/wxcheckByMemberMiMaAndId/{miMa}", method = RequestMethod.GET)
    public Boolean wxcheckByMemberMiMaAndId(@PathVariable String miMa) throws BusinessException {
        return wxMemberService.checkByMemberMiMaAndId(miMa);
    }

    @ApiOperation(value = "获取当时时间戳", notes = "时间戳", position = 2)
    @RequestMapping(value = "/wxgetcurrentDate", method = RequestMethod.GET)
    public Long wxgetcurrentDate() throws BusinessException {
        return wxMemberService.getcurrentDate();
    }

}
